home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Linux
/
Kubuntu 8.10
/
kubuntu-8.10-desktop-i386.iso
/
casper
/
filesystem.squashfs
/
usr
/
sbin
/
lilo_find_mbr
< prev
next >
Wrap
Text File
|
2008-05-15
|
715b
|
36 lines
#!/usr/bin/perl
my $root_part;
if($#ARGV != -1)
{
$root_part = $ARGV[0];
}
else
{
$root_part = `awk '{ if (\$2=="/") print \$1}' </etc/fstab`;
}
my $lilo_root_part;
foreach $item (split("\n", $root_part))
{
if(not $item =~ /#/)
{
$lilo_root_part = $item;
}
}
if($lilo_root_part =~ /\/dev\/md/)
{
my $mdname = $lilo_root_part;
$mdname =~ s/\/dev\///;
$mdname =~ s/\///;
my $md = `grep $mdname /proc/mdstat`;
my @devices = split(" ", $md);
@devices = sort(@devices[4..$#devices]);
$lilo_root_part = "/dev/" . $devices[0];
$lilo_root_part =~ s/\[.*$//;
}
my $lilo_root_disk = $lilo_root_part;
$lilo_root_disk =~ s/\d+$//;
$lilo_root_disk =~ s/part$/disc/;
print $lilo_root_disk . "\n";